<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  window.onload=function (ev) {

    // 1.获取属性
    // (1)获取所有的属性:
    console.log(document.getElementsByTagName("img")[0].attributes);
    // (2)获取指定属性:
    console.log(document.getElementsByTagName("img")[0].getAttribute("title"));
    // 2.设置、修改属性
    document.getElementsByTagName("img")[0].setAttribute("width","20px");
    document.getElementsByTagName("img")[0].setAttribute("title","我是修改的");
    // 3.删除属性
    document.getElementsByTagName("img")[0].removeAttribute("alt");
  }
</script>
<img src="../../img/4.25/1.jpg" alt="提示文字" title="我是一个图片"/>

</body>
</html>
